//
//  main.m
//  Demo0003
//
//  Created by zTercel on 12-12-26.
//  Copyright (c) 2012年 zTercel. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef unsigned int uint;

@interface Computer : NSObject
{
    char    m_coreNum;
    uint   m_romSize;        // in MB
    uint   m_ramSize;        // in MB
    char    m_osName[64];
}

-(char) coreNum;
-(void) setCoreNum:(char)coreNum;

-(uint) romSize;
-(void) setRomSize:(uint)romSize;

-(uint) ramSize;
-(void) setRamSize:(uint)ramSize;

-(char*) osName;
-(void) setOSName:(const char*) osName;

-(void) print;

-(void) startup;
-(void) shutdown;
-(void) run;

@end

@implementation Computer : NSObject

-(char) coreNum
{
    return m_coreNum;
}

-(void) setCoreNum:(char)coreNum
{
    m_coreNum = coreNum;
}

-(uint) romSize
{
    return m_romSize;
}

-(void) setRomSize:(uint)romSize
{
    m_romSize = romSize;
}

-(uint) ramSize
{
    return m_ramSize;
}

-(void) setRamSize:(uint)ramSize
{
    m_ramSize = ramSize;
}

-(char*) osName
{
    return m_osName;
}

-(void) setOSName:(const char*) osName
{
    strcpy(m_osName, osName);
}

-(void) print
{
    NSLog(@"\nComputer config infomation: \n...Core Num: %d \n...Rom Size: %uMB \n...Ram Size: %uMB\n...OS Name:  %s", m_coreNum, m_romSize, m_ramSize, m_osName);
}

-(void) startup
{
    
    NSLog(@"startup...\n");
}

-(void) shutdown
{
    NSLog(@"shutdown...\n");
}

-(void) run
{
    NSLog(@"running...\n");
}

@end



int main(int argc, const char * argv[])
{

    @autoreleasepool { 
        Computer* zTercelComputer = [[Computer alloc] init];
        [zTercelComputer setCoreNum:4];
        [zTercelComputer setOSName: "mac os x"];
        [zTercelComputer setRomSize: 500 * 1024];
        [zTercelComputer setRamSize: 2 * 1024];
       
        [zTercelComputer print];
        
        [zTercelComputer startup];
        [zTercelComputer run];
        [zTercelComputer shutdown];
        
        NSLog(@"\nI want to Update my computer config...\n");
        [zTercelComputer setRamSize: 4 * 1024];
        [zTercelComputer setOSName: "windows 8"];
        [zTercelComputer print];
        NSLog(@"\nMemory size: %dGB Hard Disk Size: %dGB", [zTercelComputer ramSize] / 1024, [zTercelComputer romSize] / 1024);
        
        
    }
    return 0;
}

